#include <iostream>
#include <string>
using namespace std;

void sxcopy1(string& s, int a, int b)
{

	string tmp(s.begin(), s.begin() + a-1);
	for (int i = a-1; i < b; i++)
	{
		tmp.append(2,s[i]);
	}
	tmp.append(s.begin() + b, s.end());
	swap(s, tmp);
}

void sxcopy2(string& s, int a, int b)
{
	for (int i = b-1; i > a; i--)
	{
		s.insert(i, 1, s[i]);
	}
}


int main()
{
	int n = 0, m = 0;
	cin >> n >> m;
	string s; int a = 0, b = 0;
	cin >> s;
	while (m--)
	{
		cin >> a >> b;
		//sxcopy1(s, a, b);

		sxcopy2(s, a, b);
	}
	
	cout << s;

	return 0;
}